$(".login-btn").click(function () {
    var check = document.getElementById("checkid");
    console.log(check.checked);
    if(check.checked == true){
        console.log("自动登录")
        autoLogin();
    }else {
        console.log("普通登录")
        login();
    }

})

function login() {
    var custAccount =  $(".custAccount").val();
    var custPassWord =  $(".custPassWord").val();

    var type ;
    if(/^[1][3,4,5,7,8][0-9]{9}$/.test(custAccount)){
        type=0;
    }else {
        type=2;
    }
    console.log(type)
// var formdata = "op=login&custAccount="+custAccount+"&custPassWord="+custPassWord+"&type="+type;
//     console.log(formdata)
    $.ajax({
        type:"POST",
        url:"/customer/login",
        data:"custAccount="+custAccount+"&custPassWord="+custPassWord+"&type="+type,
        datatype:"json",
        success:function (jsonResult) {
            console.log(jsonResult)
            if(jsonResult.status == 1){
                console.log("登录成功");
                $(".error-msg").hide();
                $(".error-msg").text("")
                window.location.href = "/index.jsp"
            }else {
                $(".error-msg").show();
                $(".error-msg").text(jsonResult.data)
            }
        }
    })
}
function autoLogin() {
    var custAccount =  $(".custAccount").val();
    var custPassWord =  $(".custPassWord").val();

    var type ;
    if(/^[1][3,4,5,7,8][0-9]{9}$/.test(custAccount)){
        type=0;
    }else {
        type=2;
    }
    console.log(type)
// var formdata = "op=login&custAccount="+custAccount+"&custPassWord="+custPassWord+"&type="+type;
//     console.log(formdata)
    $.ajax({
        type:"POST",
        url:"/customer/autoLogin",
        data:"custAccount="+custAccount+"&custPassWord="+custPassWord+"&type="+type,
        datatype:"json",
        success:function (jsonResult) {
            console.log(jsonResult)
            if(jsonResult.status == 1){
                console.log("登录成功");
                $(".error-msg").hide();
                $(".error-msg").text("")
                window.location.href = "/index.jsp"
            }else {
                $(".error-msg").show();
                $(".error-msg").text(jsonResult.data)
            }
        }
    })
}









$("#type1").click(function () {
    console.log("账号");
    $(".pswd").css('display','block');
    $(".tel-code").css('display','none');
})
$("#type2").click(function () {
    console.log("短信");
    $(".pswd").css('display','none');
    $(".tel-code").css('display','block');
})

